package kz.epam.creator;

import java.util.HashMap;
import kz.epam.apartment.Flat;
import kz.epam.homedevices.DeviceKind;
import kz.epam.homedevices.ElectricalDevice;
import kz.epam.resources.ResourceManager;

/**
 *
 * @author Knoppix
 */
// Adding values from properties
public class FlatFiller {

    public Flat fillFlat() {
        Flat flat = new Flat();
        //добавляем в квартиру девайсы
        flat.getDevices().add(getMachiningDevice());
        flat.getDevices().add(getMachiningDeviceTwo());
        flat.getDevices().add(getComputingDevice());
        flat.getDevices().add(getComputingDeviceTwo());
        flat.getDevices().add(getComputingDeviceThree());
        flat.getDevices().add(getMeasutingDevice());        
        flat.getDevices().add(getLightingDevice());
        flat.getDevices().add(getVideoBroadcastingDevice());
        flat.getDevices().add(getCommunicationDevice());
        flat.getDevices().add(getStorageProductsDevice());
        return flat;
    }

    private ElectricalDevice getMachiningDevice() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.MACHINING);

        HashMap<String, String> properties = new HashMap<>();
        properties.put("frequency", rm.getValue("MachiningDevice.frequency"));
        properties.put("type", rm.getValue("MachiningDevice.type"));
        properties.put("cardinality", rm.getValue("MachiningDevice.cardinality"));
        properties.put("maker", rm.getValue("MachiningDevice.maker"));
        properties.put("powerOn", rm.getValue("MachiningDevice.powerOn"));

        return builder.create(properties);
    }

    private ElectricalDevice getMachiningDeviceTwo() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.MACHINING);

        //формируем сиписок параметров
        HashMap<String, String> properties = new HashMap<>();
        properties.put("frequency", rm.getValue("MachiningDeviceTwo.frequency"));
        properties.put("type", rm.getValue("MachiningDeviceTwo.type"));
        properties.put("cardinality", rm.getValue("MachiningDeviceTwo.cardinality"));
        properties.put("maker", rm.getValue("MachiningDeviceTwo.maker"));
        properties.put("powerOn", rm.getValue("MachiningDeviceTwo.powerOn"));

        //создаем и возвращаем ее на верх
        return builder.create(properties);
    }

    private ElectricalDevice getComputingDevice() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.COMPUTING);

        //формируем сиписок параметров
        HashMap<String, String> properties = new HashMap<>();
        properties.put("cpuSpeed", rm.getValue("ComputingDevice.cpuSpeed"));
        properties.put("type", rm.getValue("ComputingDevice.type"));
        properties.put("cardinality", rm.getValue("ComputingDevice.cardinality"));
        properties.put("maker", rm.getValue("ComputingDevice.maker"));
        properties.put("powerOn", rm.getValue("ComputingDevice.powerOn"));

        //создаем и возвращаем ее на верх
        return builder.create(properties);        
    }

    private ElectricalDevice getComputingDeviceTwo() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.COMPUTING);

        //формируем сиписок параметров
        HashMap<String, String> properties = new HashMap<>();
        properties.put("cpuSpeed", rm.getValue("ComputingDeviceTwo.cpuSpeed"));
        properties.put("type", rm.getValue("ComputingDeviceTwo.type"));
        properties.put("cardinality", rm.getValue("ComputingDeviceTwo.cardinality"));
        properties.put("maker", rm.getValue("ComputingDeviceTwo.maker"));
        properties.put("powerOn", rm.getValue("ComputingDeviceTwo.powerOn"));

        //создаем и возвращаем ее на верх
        return builder.create(properties);  
    }

    private ElectricalDevice getComputingDeviceThree() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.COMPUTING);

        //формируем сиписок параметров
        HashMap<String, String> properties = new HashMap<>();
        properties.put("cpuSpeed", rm.getValue("ComputingDeviceThree.cpuSpeed"));
        properties.put("type", rm.getValue("ComputingDeviceThree.type"));
        properties.put("cardinality", rm.getValue("ComputingDeviceThree.cardinality"));
        properties.put("maker", rm.getValue("ComputingDeviceThree.maker"));
        properties.put("powerOn", rm.getValue("ComputingDeviceThree.powerOn"));

        //создаем и возвращаем ее на верх
        return builder.create(properties); 
    }

 

    private ElectricalDevice getMeasutingDevice() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.INSTRUMENTATION);

        //формируем сиписок параметров
        HashMap<String, String> properties = new HashMap<>();
        properties.put("value", rm.getValue("MeasuringDevice.value"));
        properties.put("type", rm.getValue("MeasuringDevice.type"));
        properties.put("cardinality", rm.getValue("MeasuringDevice.cardinality"));
        properties.put("maker", rm.getValue("MeasuringDevice.maker"));
        properties.put("powerOn", rm.getValue("MeasuringDevice.powerOn"));

        //создаем и возвращаем ее на верх
        return builder.create(properties);
    }

    private ElectricalDevice getLightingDevice() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.LIGHTING);

        //формируем сиписок параметров
        HashMap<String, String> properties = new HashMap<>();
        properties.put("luminousEfficiency", rm.getValue("Lighting.luminousEfficiency"));
        properties.put("type", rm.getValue("Lighting.type"));
        properties.put("cardinality", rm.getValue("Lighting.cardinality"));
        properties.put("maker", rm.getValue("Lighting.maker"));
        properties.put("powerOn", rm.getValue("Lighting.powerOn"));

        //создаем и возвращаем ее на верх
        return builder.create(properties);
    }

    private ElectricalDevice getVideoBroadcastingDevice() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.VIDEO_BROADCASTING);

        //формируем сиписок параметров
        HashMap<String, String> properties = new HashMap<>();
        properties.put("screenDiagonal", rm.getValue("VideoBroadcastingDevice.screenDiagonal"));
        properties.put("type", rm.getValue("VideoBroadcastingDevice.type"));
        properties.put("cardinality", rm.getValue("VideoBroadcastingDevice.cardinality"));
        properties.put("maker", rm.getValue("VideoBroadcastingDevice.maker"));
        properties.put("powerOn", rm.getValue("VideoBroadcastingDevice.powerOn"));

        //создаем и возвращаем ее на верх
        return builder.create(properties);
    }

    private ElectricalDevice getCommunicationDevice() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.COMMUNICATION);

        //формируем сиписок параметров
        HashMap<String, String> properties = new HashMap<>();
        properties.put("number", rm.getValue("CommunicationDevice.number"));
        properties.put("type", rm.getValue("CommunicationDevice.type"));
        properties.put("cardinality", rm.getValue("CommunicationDevice.cardinality"));
        properties.put("maker", rm.getValue("CommunicationDevice.maker"));
        properties.put("powerOn", rm.getValue("CommunicationDevice.powerOn"));

        //создаем и возвращаем ее на верх
        return builder.create(properties);
    }

    private ElectricalDevice getStorageProductsDevice() {
        //подготавливаем обслуживающие классы
        ResourceManager rm = ResourceManager.getInstanse();
        DeviceBuilder builder = new DeviceBuilder();
        builder.setType(DeviceKind.STORAGE_PRODUCTS);

        //формируем сиписок параметров
        HashMap<String, String> properties = new HashMap<>();
        properties.put("temperature", rm.getValue("StorageProductsDevice.temperature"));
        properties.put("type", rm.getValue("StorageProductsDevice.type"));
        properties.put("cardinality", rm.getValue("StorageProductsDevice.cardinality"));
        properties.put("maker", rm.getValue("StorageProductsDevice.maker"));
        properties.put("powerOn", rm.getValue("StorageProductsDevice.powerOn"));

        //создаем и возвращаем ее на верх
        return builder.create(properties);
    }
}
